import java.sql.*;

public class jdbc {
    public static void main(String[] args) throws ClassNotFoundException, SQLException {
        Class.forName("com.mysql.cj.jdbc.Driver");
        // 获取驱动
        String url = "jdbc:mysql://localhost:3306/mysql?useUnicode=true&characterEnding=utf8&useSSL=true";
        String username ="root";
        String password ="123456";
        Connection connection = DriverManager.getConnection(url,username,password);
        //找到数据库
        Statement statement = connection.createStatement();
        String sql = "SELECT*FROM practice";
        ResultSet resultSet = statement.executeQuery(sql);
        //执行SQL操作对象
        while(resultSet.next()){
            String one = resultSet.getString(1);
            String two = resultSet.getString(2);
            String three = resultSet.getString(3);
            System.out.println("姓名"+two+"年龄"+one+"籍贯"+three);}
        //获取执行结果    结果处理
        resultSet.close();
        statement.close();
        connection.close();
        //关闭
    }}
